//
//  HomeViewController.m
//  QSBK
//
//  Created by Eric Wang on 4/17/15.
//  Copyright (c) 2015 Eric Wang. All rights reserved.
//
#import <ShareSDK/ShareSDK.h>
#import "ChatViewController.h"
#import "NothingViewController.h"
#import "FriendViewController.h"
#import "AppDelegate.h"
#import "GameCenter.h"
#import "ProfileInfoController.h"
#import "UserData.h"
#import "UIImageView+WebCache.h"
#import "ProfileLoginControllerViewController.h"
#import "CheckViewController.h"
#import "PublishViewController.h"
#import "CommentViewController.h"
#import "Common.h"
#import "AFNetworking.h"
#import "User.h"
#import "Blog.h"
#import "BlogFrame.h"
#import "BlogCell.h"

#import "ProfileLoginControllerViewController.h"
#import "HomeViewController.h"
#import "NearByController.h"
#import "NearPeopleController.h"
@interface HomeViewController ()<UITableViewDataSource,UITableViewDelegate,BottomBar,TopBar,MenuBar,ProfileLoginControllerViewController,NearByController,BlogCell,CommentViewController,FriendViewController>
@property(nonatomic,strong)UILabel *statusLabel;
@property(nonatomic,strong)TopBar *topbar;
@property(nonatomic,strong)UIView *contentView;
@property(nonatomic,strong)UITableView *contentTableView;
@property(nonatomic,strong)BottomBar *bottombar;
@property(nonatomic,strong)MenuBar *menubar;
@property(nonatomic,strong)UIView *currentView;
@property(nonatomic,strong)ProfileLoginControllerViewController *login;
@property(nonatomic,strong)FriendViewController *friend;
//
@property(nonatomic,strong)NearByController *nearBy;
@property(nonatomic,strong)CommentViewController *comment;
//button index
@property(nonatomic,assign)int buttonIndex;

@property(nonatomic,strong)AppDelegate *delegate;
//refreshControl
@property(nonatomic,strong)UIRefreshControl *up;
//login fail
@property(nonatomic,strong)UIView *loginFail;
//chat withOut no user
@property(nonatomic,strong)NothingViewController *nothing;
//info of page
@property(nonatomic,assign)int page;
//info type
@property(nonatomic,copy)NSString *infoType;
@end

@implementation HomeViewController

//-(void)configUserHeadImage
//{
//    AppDelegate *delegate = [UIApplication sharedApplication].delegate;
//    if(delegate.user!=nil)
//    {
//        self.topbar.profile.hidden = YES;
//        self.topbar.headImage.hidden = NO;
//    }else{
//        self.topbar.profile.hidden = NO;
//        self.topbar.headImage.hidden = YES;
//    }
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addAllSubViews];
    [self getData:@"suggest" isRefresh:NO];
    [self setAllChildController];
    if(self.delegate.user!=nil)
    {
        [self afterLoginSuccess:self.delegate.user.login];
    }
//    [self createTableFootView];
    //[self configUserHeadImage];
    // Do any additional setup after loading the view.
}
//-(void)createTableFootView
//{
//    CGFloat W = self.contentTableView.frame.size.width;
//    UIView *footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.contentTableView.frame.size.width, 100)];
//    UIActivityIndicatorView *act = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake((W-30)/2 , 5, 30, 30)];
//    act.tintColor = [UIColor blackColor];
//    UILabel *TextLabel = [[UILabel alloc]initWithFrame:CGRectMake((W-80)/2, 55, 80, 30)];
//    [act startAnimating];
//    TextLabel.text = @"上拉刷新" ;
//   
//    [footView addSubview:act];
//    [footView addSubview:TextLabel];
//    self.contentTableView.tableFooterView = footView;
//}

-(void)setAllChildController
{
    self.nearBy = [[NearByController alloc]init];
    self.nearBy.delegate = self;
    self.nearBy.view.frame = self.contentView.frame;
    
    self.comment = [[CommentViewController alloc]initWithNibName:@"CommentViewController" bundle:nil];
    self.comment.delegate = self;
    
    self.friend = [[FriendViewController alloc]initWithNibName:@"FriendViewController" bundle:nil];
    self.friend.view.frame = self.contentView.frame;
    self.friend.delegate  = self;
    
    
    self.nothing = [[NothingViewController alloc]initWithNibName:@"NothingViewController" bundle:nil];
    self.nothing.view.frame = self.contentView.frame;
}

- (void)addAllSubViews
{
    
    self.delegate = [UIApplication sharedApplication].delegate;
    //LoginViewController
    self.login = [[ProfileLoginControllerViewController alloc]initWithNibName:@"ProfileLoginControllerViewController" bundle:nil];
    self.login.delegate = self;
    //
    self.buttonIndex = 1;
  
    self.view.backgroundColor = [UIColor whiteColor];
    
    //tpbar
    self.topbar = [[TopBar alloc]initWithFrame:CGRectMake(0, StatusBarH, ScreenW, 40)];
    self.topbar.delegate = self;
    self.topbar.backgroundColor = [UIColor colorWithRed:254/255.0 green:200/255.0 blue:5/255.0 alpha:1.0];
    [self.view addSubview:self.topbar];
    
    
    //contentView
    self.contentView = [[UIView alloc]initWithFrame:CGRectMake(0, StatusBarH+40, ScreenW, ScreenH-StatusBarH-40)];
    self.currentView = self.contentView;
    [self.view addSubview:self.contentView];
    
    //menuBar
    self.menubar = [[MenuBar alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 40)];
    self.menubar.delegate=self;
    self.menubar.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.menubar];
    //tableview
    self.contentTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 40, ScreenW, self.contentView.frame.size.height-40)];
    //self.contentTableView.allowsSelection = NO;
    self.contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.contentTableView.delegate = self;
    self.contentTableView.dataSource = self;
    self.contentTableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 2)];
    self.contentTableView.tableHeaderView.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1.0];
    self.contentTableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 10)];
    self.contentTableView.tableFooterView.backgroundColor=[UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1.0];
    
    [self.contentView addSubview:self.contentTableView];
    
    //bottombar
    
    self.bottombar = [[BottomBar alloc]initWithFrame:CGRectMake(0, self.contentView.bounds.size.height, ScreenW, 48)];
    self.bottombar.delegate = self;
    self.bottombar.backgroundColor = [UIColor colorWithRed:254/255.0 green:200/255.0 blue:5/255.0 alpha:1.0];
    [self.contentView addSubview:self.bottombar];
    
    self.currentView = self.contentView;
    
    
    self.up = [[UIRefreshControl alloc]init];
    self.up.attributedTitle = [[NSAttributedString alloc]initWithString:@"下拉获取最新信息"];
    [self.up addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
    [self.contentTableView addSubview:self.up];
    
    //status label
    self.statusLabel = [[UILabel alloc]init];
    [self.statusLabel.layer setCornerRadius:5.0];
    self.statusLabel.layer.masksToBounds = YES;
    self.statusLabel.alpha = 0.9;
    self.statusLabel.hidden = YES;
    self.statusLabel.backgroundColor = [UIColor blackColor];
    [self.statusLabel setTextColor:[UIColor whiteColor]];
    self.statusLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:15];
    self.statusLabel.numberOfLines = 0;
    [self.view addSubview:self.statusLabel];
    
    //login fail
    
//    self.loginFail = [[UIView alloc]initWithFrame:self.contentTableView.frame];
//    self.loginFail.hidden = YES;
//    [self.view addSubview:self.loginFail];
//    
//    UIButton *tryAgain = [[UIButton alloc]initWithFrame:CGRectMake((self.loginFail.frame.size.width-80)/2,(self.loginFail.frame.size.height-30)/2,80,30)];
//    [self.loginFail addSubview:tryAgain];
    
    [self afterLoginSuccess:@"welcome back"];
}

-(void)showStatusLabel:(NSString *)string
{
    UIFont *fnt = [UIFont fontWithName:@"HelveticaNeue" size:15];
    CGRect statusLabelSize = [string boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:fnt,NSFontAttributeName, nil] context:nil];
    self.statusLabel.frame = CGRectMake((ScreenW-statusLabelSize.size.width-5)/2, (ScreenH-statusLabelSize.size.height-65), statusLabelSize.size.width+5, statusLabelSize.size.height+5);
    
    self.statusLabel.text = string;
    [UIView animateWithDuration:0.2 animations:^{
        self.statusLabel.hidden = NO;
    }];
    [self performSelector:@selector(updateStatusLabel) withObject:nil afterDelay:1.0];
}

-(void)updateStatusLabel
{
    [UIView animateWithDuration:0.3 animations:^{
        self.statusLabel.hidden = YES;
    }];
}

#pragma mark tableView delegate datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _blogFrameArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    BlogCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    if(cell == nil)
    {
        cell = [[BlogCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.delegate=self;
    cell.blogFrame = _blogFrameArray[indexPath.row];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return (CGFloat)((BlogFrame *)_blogFrameArray[indexPath.row]).cellHeight;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    BlogCell *cell = (BlogCell *)[self.contentTableView cellForRowAtIndexPath:indexPath];
    
    self.comment.headCell = [[BlogCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"commentCell"];
    self.comment.headCell.blogFrame = cell.blogFrame;
    
    [self presentViewController:self.comment animated:YES completion:nil];
}


-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{

    CGFloat y = self.contentView.bounds.size.height-48;
    if(scrollView.isDragging)
    {
        if(scrollView.contentOffset.y<distance)
        {
            [UIView animateWithDuration:0.25 animations:^{
                self.bottombar.frame = CGRectMake(0,y , ScreenW, 48);
            }completion:nil];
            
        }else{
            [UIView animateWithDuration:0.25 animations:^{
                self.bottombar.frame= CGRectMake(0, self.contentView.bounds.size.height, ScreenW, 48);
            }completion:nil];
        }
    }
    
    distance = scrollView.contentOffset.y;
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    if(scrollView.contentOffset.y>self.contentTableView.contentSize.height/2)
    {
        NSLog(@"%f--%f",scrollView.contentOffset.y,self.contentTableView.contentSize.height);
        [self getData:self.infoType isRefresh:YES];
    }
}


- (void)turnToOtherController:(int)tag
{
    switch (tag) {
        case 997:
            [self.currentView removeFromSuperview];
            [self.view addSubview:self.contentView];
            self.currentView = self.contentView;
            break;
        case 998:
            [self.currentView removeFromSuperview];
            [self.view addSubview:self.nearBy.view];
            self.currentView = self.nearBy.view;
            break;
        case 999:
            self.delegate = [UIApplication sharedApplication].delegate;
            if(self.delegate.user!=nil)
            {
                
                [self.currentView removeFromSuperview];
                [self.view addSubview:self.friend.view];
                self.friend.user = self.delegate.user;
                self.currentView = self.friend.view;
            }else{
                [self.currentView removeFromSuperview];
                [self.view addSubview:self.nothing.view];
                self.currentView = self.nothing.view;
            }
            
            break;
            
        default:
            break;
    }
}

- (void)turnTOMoreChoices
{
    
}

- (void)turnToLogin
{

    [self presentViewController:self.login animated:YES completion:nil];
}


#pragma look User Info
-(void)lookUserInfo
{
    
    ProfileInfoController *profileInfo = [[ProfileInfoController alloc]initWithNibName:@"ProfileInfoController" bundle:nil];
    profileInfo.user = self.delegate.user;
    profileInfo.image = self.topbar.headImage.image;
    [self presentViewController:profileInfo animated:YES completion:nil];
}
//

-(void)afterLoginSuccess:(NSString *)string
{
    [self showStatusLabel:string];
    self.delegate = [UIApplication sharedApplication].delegate;
    if(self.delegate.user!=nil)
    {
        self.topbar.profile.hidden = YES;
        [self.topbar.headImage sd_setImageWithURL:[NSURL URLWithString:self.delegate.user.icon] placeholderImage:[UIImage imageNamed:@"default_users_avatar.png"]];
    }else{
        self.topbar.profile.hidden = NO;
    }
}


//getData from internet
-(void)getData:(NSString *)str isRefresh:(BOOL)refresh
{
    self.infoType = str;
    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
    rotationAnimation.duration = 1.5;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = MAXFLOAT;
    self.topbar.refreshView.hidden = NO;
    [self.topbar.refreshView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

    
    
    NSString *string=nil;
    if(refresh)
    {
        self.page = self.page + 2;
        //string = [NSString stringWithFormat:@"http://m2.qiushibaike.com/article/list/%@?page=1&type=refresh",str];
        string = [NSString stringWithFormat:@"http://localhost:8888/thinkphp_3.2.3/Home/QSBK/%@?page=%d",str,self.page];
    }else{
        self.page = 0;
        if(_blogFrameArray==nil){
            _blogFrameArray = [[NSMutableArray alloc]init];
        }
        
        if(_blogFrameArray.count)
        {
            [_blogFrameArray removeAllObjects];
        }
        string = [NSString stringWithFormat:@"http://localhost:8888/thinkphp_3.2.3/Home/QSBK/%@?page=%d",str,self.page];
    }
   

    NSURL *url = [NSURL URLWithString:string];
    NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url];
    
    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
    
    [operation start];
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation,id responseObject){
        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:(NSData *)responseObject options:NSJSONReadingMutableContainers error:nil];
        NSArray *array = [dictionary objectForKey:@"item"];
        for (NSDictionary *dic in array)
        {
       
            User *user = [[User alloc]init];
            Blog *blog = [[Blog alloc]init];
            
            user.user_id = [dic objectForKey:@"user_id"];
            user.articleTotal = [dic objectForKey:@"total"];
            user.stater = [dic objectForKey:@"stater"];
            user.role = [dic objectForKey:@"role"];
            user.sex = [dic objectForKey:@"sex"];
            user.longitude = [dic objectForKey:@"longitude"];
            user.latitude = [dic objectForKey:@"latitude"];
            user.login = [dic objectForKey:@"login"];
            user.last_visited_at = [dic objectForKey:@"last_visited"];
            user.last_device = [dic objectForKey:@"last_device"];
            user.icon = [dic objectForKey:@"icon"];
            user.email = [dic objectForKey:@"email"];
            blog.user = user;
            
            blog.allow_comment = [[dic objectForKey:@"allow_comment"] intValue];
            blog.article_id = [dic objectForKey:@"article_id"];
            blog.comments_count = [dic objectForKey:@"comments_count"];
            blog.content = [dic objectForKey:@"content"];
            blog.created_at = [dic objectForKey:@"created_at"];
            blog.image = [dic objectForKey:@"image"];
            blog.image_height = [dic objectForKey:@"image_height"];
            blog.image_width = [dic objectForKey:@"image_width"];
            blog.tag = [dic objectForKey:@"tag"];
            blog.up = [dic objectForKey:@"up"];
            blog.down = [dic objectForKey:@"down"];
            blog.state = [dic objectForKey:@"state"];
            blog.published_at = [dic objectForKey:@"published_at"];
            
            BlogFrame *frame = [[BlogFrame alloc]init];
            frame.blog = blog;
            [_blogFrameArray addObject:frame];
        }
        
        dispatch_async(dispatch_get_main_queue(), ^{
            
            [self.contentTableView reloadData];
            [self.topbar.refreshView.layer removeAllAnimations];
            self.topbar.refreshView.hidden = YES;
        });
        
    }failure:^(AFHTTPRequestOperation *operation,NSError *error){
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.topbar.refreshView.layer removeAllAnimations];
             self.topbar.refreshView.hidden = YES;
            [self showStatusLabel:@"加载失败,请稍后重试!"];
            [self showLoginFail];
            [self.up endRefreshing];
        });
        
    }];


}

//show login fail

-(void)showLoginFail
{
    
}

- (void)didChooseMenuOnButtonIndex:(int)buttonIndex
{
    switch (buttonIndex) {
        case 1:
            [self getData:@"suggest" isRefresh:NO];
            break;
        case 2:
            [self getData:@"video" isRefresh:NO];
            break;
        case 3:
            [self getData:@"text" isRefresh:NO];
            break;
        case 4:
            [self getData:@"imgrank" isRefresh:NO];
            break;
        case 5:
            [self getData:@"day" isRefresh:NO];
            break;
        case 6:
            [self getData:@"latest" isRefresh:NO];
            break;
        default:
            break;
    }
    self.buttonIndex = buttonIndex;
}

-(void)refreshData
{
    switch (self.buttonIndex) {
        case 1:
            [self getData:@"suggest" isRefresh:YES];
            break;
        case 2:
            [self getData:@"video" isRefresh:YES];
            break;
        case 3:
            [self getData:@"text" isRefresh:YES];
            break;
        case 4:
            [self getData:@"imgrank" isRefresh:YES];
            break;
        case 5:
            [self getData:@"day" isRefresh:YES];
            break;
        case 6:
            [self getData:@"latest" isRefresh:YES];
            break;
        default:
            break;
    }
}



//publishView
-(void)openPublishView
{
        if(self.delegate.user!=nil){
        PublishViewController *publish = [[PublishViewController alloc]init];
        [self presentViewController:publish animated:YES completion:nil];
    }else{
        [self presentViewController:self.login animated:YES completion:nil];
    }
}
//checkview
-(void)openCheckView
{
   
    if(self.delegate.user!=nil)
    {
        CheckViewController *chech = [[CheckViewController alloc]initWithNibName:@"CheckViewController" bundle:nil];
        [self presentViewController:chech animated:YES completion:nil];
    }else{
        ProfileLoginControllerViewController *login = [[ProfileLoginControllerViewController alloc]initWithNibName:@"ProfileLoginControllerViewController" bundle:nil];
        [self presentViewController:login animated:YES completion:nil];
        
        
    }
    
}

//ture to NearBy
-(void)presentToNearByController
{
    GameCenter *game = [[GameCenter alloc]initWithNibName:@"GameCenter" bundle:nil];
    [self presentViewController:game animated:YES completion:nil];
}
//ture to near people
-(void)presentToNearPeoPleController
{
    AppDelegate *delegate = [UIApplication sharedApplication].delegate;
    if(delegate.user!=nil)
    {
    NearPeopleController *nearPeople = [[NearPeopleController alloc]initWithNibName:@"NearPeopleController" bundle:nil];
    [self presentViewController:nearPeople animated:YES completion:nil];
    }else{
        [self presentViewController:self.login animated:YES completion:nil];
    }
}
#pragma 点赞

-(void)ClickUpWithCell:(BlogCell *)cell
{
    NSString *urlString = @"http://localhost:8888/thinkphp_3.2.3/Home/QSBK/up?";
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *para = @{@"article_id":cell.blogFrame.blog.article_id};
    [manager POST:urlString parameters:para success:^(AFHTTPRequestOperation *operation,id responseObject){
        
    }failure:^(AFHTTPRequestOperation *operation,NSError *error)
    {
        
    }];
}

-(void)ClickDownWithCell:(BlogCell *)cell
{
    NSString *urlString = @"http://localhost:8888/thinkphp_3.2.3/Home/QSBK/down?";
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *para = @{@"article_id":cell.blogFrame.blog.article_id};
    [manager POST:urlString parameters:para success:^(AFHTTPRequestOperation *operation,id responseObject){
        
    }failure:^(AFHTTPRequestOperation *operation,NSError *error)
     {
         
     }];
}

-(void)ClickCommentWithCell:(BlogCell *)cell
{
    self.comment.headCell = [[BlogCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"commentCell"];
    self.comment.headCell.blogFrame = cell.blogFrame;
    
    [self presentViewController:self.comment animated:YES completion:nil];
}

- (void)ClickMoreWithCell:(BlogCell *)cell
{

    NSLog(@"打开分享界面");
    NSArray *shareList = [ShareSDK getShareListWithType:
                          ShareTypeWeixiSession,
                          ShareTypeWeixiTimeline,
                          ShareTypeSinaWeibo,
                          ShareTypeTencentWeibo,
                          ShareTypeSMS,
                          ShareTypeMail,
                          nil];
    
    //构造分享内容
    id<ISSContent> publishContent = [ShareSDK content:@"test"
                                       defaultContent:@"test"
                                                image:nil
                                                title:@"甜蜜街"
                                                  url:@""
                                          description:@"test"
                                            mediaType:SSPublishContentMediaTypeNews];
    
    
    //创建弹出菜单容器
    
    id<ISSContainer> container = [ShareSDK container];
    //    [container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
    
    id<ISSAuthOptions> authOptions = [ShareSDK authOptionsWithAutoAuth:YES
                                                         allowCallback:NO
                                                         authViewStyle:SSAuthViewStyleFullScreenPopup
                                                          viewDelegate:nil
                                               authManagerViewDelegate:nil];
    
    //在授权页面中添加关注官方微博
    [authOptions setFollowAccounts:[NSDictionary dictionaryWithObjectsAndKeys:
                                    [ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
                                    SHARE_TYPE_NUMBER(ShareTypeSinaWeibo),
                                    [ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
                                    SHARE_TYPE_NUMBER(ShareTypeTencentWeibo),
                                    nil]];
    
    id<ISSShareOptions> shareOptions = [ShareSDK defaultShareOptionsWithTitle:@"分享"
                                                              oneKeyShareList:shareList
                                                               qqButtonHidden:YES
                                                        wxSessionButtonHidden:YES
                                                       wxTimelineButtonHidden:YES
                                                         showKeyboardOnAppear:NO
                                                            shareViewDelegate:nil
                                                          friendsViewDelegate:nil
                                                        picViewerViewDelegate:nil];
    
    //弹出分享菜单
    [ShareSDK showShareActionSheet:container
                         shareList:shareList
                           content:publishContent
                     statusBarTips:YES
                       authOptions:authOptions
                      shareOptions:shareOptions
                            result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
                                
                                if (state == SSResponseStateSuccess)
                                {
                                    NSLog(@"分享成功");
                                }
                                else if (state == SSResponseStateFail)
                                {
                                    NSLog(@"分享失败,错误码:%d,错误描述:%@", [error errorCode], [error errorDescription]);
                                }
                            }];}
#pragma CommentViewController
-(void)needLoginBeforeComment
{
    [self presentViewController:self.login animated:YES completion:nil];
}

#pragma FriendListViewController
-(void)turnToChatViewController:(User *)user
{
    ChatViewController *chat = [[ChatViewController alloc]init];
                                //WithNibName:@"ChatViewController" bundle:nil];
    [self presentViewController:chat animated:YES completion:nil];
}
@end
